package com.xthink.web.controller;

import com.xthink.common.result.AjaxResult;
import com.xthink.common.vo.sys.RoleInsertVo;
import com.xthink.common.vo.sys.RoleUpdateVo;
import com.xthink.web.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/role")
public class RoleController {
    @Autowired
    private RoleService roleService;


    /*
    * 添加角色
    * */
    @PostMapping("/insert")
    public AjaxResult insertRole(@RequestBody RoleInsertVo roleInsertVo){
        return roleService.insertRole(roleInsertVo);
    }

    /*
    * 编辑角色
    * */
    @PostMapping("/update")
    public AjaxResult updateRole(@RequestBody RoleUpdateVo roleUpdateVo){
        return roleService.updateRole(roleUpdateVo);
    }

    /*
    * 查询角色组
    * */
    @PostMapping("/list")
    public AjaxResult listRole(){
        return roleService.listRole();
    }

    /*
    * 删除角色组
    * */
    @GetMapping("/delete/{id}")
    public AjaxResult deleteRole(@PathVariable("id") Integer id){
        return roleService.deleteRole(id);
    }

    /*
    * 父级下拉框
    * */
    @RequestMapping("/parent")
    public AjaxResult parent(){
        return roleService.parent();
    }
}
